package sauvegarde;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

import modele.Case;
import modele.GrilleModele;
import modele.Joueur;




/**
 * 
 * @author MARIEM MOUAKHAR
 * @version 1.0
 */
public class Sauvegarde {     
	/**
	 * sauvegarde la grille modele dans le fichier "toto"
	 * @param project
	 * @param Gm
	 * @throws IOException
	 */
	public static void sauvegarder (String project, GrilleModele Gm) throws IOException{
		 File fichier= new File(".//test//"+project);
		 try {
	         ObjectOutputStream flotEcriture = 
	             new ObjectOutputStream(
	                new FileOutputStream(fichier));
	         flotEcriture.writeObject(Gm);
	         flotEcriture.close();
	       } catch (IOException e) {
	         System.out.println(" erreur :" + e.toString());
	       }   

		
		
	}
	
	/**
	 * charge la grille modele du fichier "totot
	 * @param project
	 * @return
	 * @throws IOException
	 */
	public static GrilleModele GrilleLoader (String project) throws IOException{
		GrilleModele lu = null;
		try{
			 ObjectInputStream flotLecture = 
	             new ObjectInputStream(new FileInputStream(".//test//"+project));
			 
			  lu =(GrilleModele)  flotLecture.readObject();
	      
	         flotLecture.close();
	       
	     } catch (Exception e) {
	       System.out.println(" erreur :" +e.toString());
	     }    
	 return lu;

		}
	
	
	
	
	
}
